home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
utility2
/
wine02bx.zip
/
LISP
/
PACKAGES
/
CONX.ELC
< prev
next >
Wrap
Text File
|
1993-03-28
|
14KB
|
40 lines
;;; compiled by jwz@thalidomide on Mon Dec 28 16:01:53 1992
;;; from file /cadillac-th/jwz/emacs19/lisp/packages/conx.el
;;; emacs version 19.4.1 Lucid.
;;; bytecomp version 2.08; 13-dec-92.
;;; optimization is on.
;;; this file uses opcodes which do not exist in Emacs18.
(if (and (boundp 'emacs-version)
(or (and (boundp 'epoch::version) epoch::version)
(string-lessp emacs-version "19")))
(error "This file was compiled for Emacs19."))
(byte-code "└┬├!¼é─┬┼!¼é╞╟╟ ╩╟╟ç" ["1.4, 28-dec-92." conx-version boundp conx-bounce 10 conx-hashtable-size 9923 nil conx-words-hashtable conx-words-vector 0 conx-words-vector-fp conx-last-word] 2)
(defvar conx-files nil "\
FYI")
(fset 'conx-init #[nil "½ìG Y½ç┬├\"ê¬à─ ├\"½ç┬╞\"ê¬à─╟╞\"├╞ ╞ë\nç" [conx-words-hashtable conx-hashtable-size fillarray 0 make-vector conx-words-vector nil 1000 conx-words-vector-fp conx-last-word conx-files] 3 "\
Forget the current word-frequency tree." nil])
(byte-code "└┴Mê┬├Mê─┼Mê╞╟Mê╚╔Mê╩╦Mê╠═Mê╬╧Mê╨╤Mê╥╙Mê╘╒Mê╓╪┘Mê┌█Mê▄▌Mç" [conx-rehash #[nil "└┴!ê\nG─ë\\┼\"╟W½ÄS\nSëHIê¬m*└╚!ç" [message "Rehashing..." conx-words-vector L make-vector nil v2 0 "Rehashing...done"] 5] conx-count (macro . #[(word) "└ ┬Eç" [aref word 0] 3]) conx-cap (macro . #[(word) "└ ┬Eç" [aref word 1] 3]) conx-comma (macro . #[(word) "└ ┬Eç" [aref word 2] 3]) conx-period (macro . #[(word) "└ ┬Eç" [aref word 3] 3]) conx-quem (macro . #[(word) "└ ┬Eç" [aref word 4] 3]) conx-bang (macro . #[(word) "└ ┬Eç" [aref word 5] 3]) conx-succ (macro . #[(word) "└ ┬Eç" [aref word 6] 3]) conx-pred (macro . #[(word) "└ ┬Eç" [aref word 7] 3]) conx-succ-c (macro . #[(word) "└ ┬Eç" [aref word 8] 3]) conx-pred-c (macro . #[(word) "└ ┬Eç" [aref word 9] 3]) 10 conx-length conx-make-word (macro . #[nil "└ç" [(copy-sequence '[1 0 0 0 0 0 nil nil 0 0])] 1]) conx-setf (macro . #[(form val) "└ ┬├!¡ü\"ë9½à─ Eç @╞=½ë╟╚ AC\"Bç @╔=½ç╩ A@Eç @╦=½ç╠ A@Eç═╬ \"ç" [macroexpand form boundp byte-compile-macro-environment setq val aref aset append cdr setcdr car setcar error "can't setf %s"] 5]) conx-push (macro . #[(thing list) "└ ┬ EEç" [conx-setf list cons thing] 5])] 2)
(defconst conx-most-positive-fixnum (byte-code "└┴ë\"ç" [lsh -1] 3) "\
The largest positive integer that can be represented in this emacs.")
(byte-code "└┴Mê┬├Mê─┼Mê╞╟Mê╚╔Mê╩╦Mç" [conx-rand (macro . #[(n) "└┴┬├EEç" [% logand conx-most-positive-fixnum (random) n] 4]) conx-relate-succ (macro . #[(word related) "└┴┬DDC─└┼╞╚EDC╔┼╩╦╠═E╬EFEFç" [let vec symbol-value word (conx-setf (conx-succ-c vec) (1+ (conx-succ-c vec))) rel assq related (conx-succ vec) if (setcdr rel (1+ (cdr rel))) conx-push cons 1 (conx-succ vec)] 12]) conx-relate-pred (macro . #[(word related) "└┴┬DDC─└┼╞╚EDC╔┼╩╦╠═E╬EFEFç" [let vec symbol-value word (conx-setf (conx-pred-c vec) (1+ (conx-pred-c vec))) rel assq related (conx-pred vec) if (setcdr rel (1+ (cdr rel))) conx-push cons 1 (conx-pred vec)] 12]) conx-add-word (macro . #[(word) "└┴┬\nD├DC─#ç" [append (let*) word (fc (aref word 0)) ((setq word (intern (downcase word) conx-words-hashtable)) (let ((vec (and (boundp word) (symbol-value word)))) (if vec (conx-setf (conx-count vec) (1+ (conx-count vec))) (if (= conx-words-vector-fp (length conx-words-vector)) (conx-rehash)) (set word (setq vec (conx-make-word))) (aset conx-words-vector conx-words-vector-fp word) (setq conx-words-vector-fp (1+ conx-words-vector-fp))) (or (< fc 65) (> fc 90) (conx-setf (conx-cap vec) (1+ (conx-cap vec))))) (if conx-last-word (progn (conx-relate-succ conx-last-word word) (conx-relate-pred word conx-last-word))) (setq conx-last-word word))] 4]) conx-punx (macro . #[(char) "└┴┬├D─D┼EEç" [if conx-last-word let char (vec (symbol-value conx-last-word)) (cond ((eq char 44) (conx-setf (conx-comma vec) (1+ (conx-comma vec)))) ((or (eq char 46) (eq char 59)) (conx-setf (conx-period vec) (1+ (conx-period vec))) (setq conx-last-word nil)) ((eq char 63) (conx-setf (conx-quem vec) (1+ (conx-quem vec))) (setq conx-last-word nil)) ((eq char 33) (conx-setf (conx-bang vec) (1+ (conx-bang vec))) (setq conx-last-word nil)))] 5]) conxify-internal #[nil "└ëm?à├└wêg─>½è┼└wê├└wê¬q`┼└wêh╞U½â╟uê\n`=¼U\n`{ë╚ܼL ë ╩H╠ ù\" ╬ !¡â Jë½î╩╩HTIê¬óGU½â╥ ê ╙╘!ëLê IêT╒W¼É╓V¼è╫╫HTIê)½ΣJë┘┘HTIê ┌H₧ë½ëëATíê¬Ä┌ ╫B┌HBIê* Jë▄▄HTIê▌H₧ë½ëëATíê¬Ä▌╫B▌HBIê* *T▀└wêgëα>â â \nJë!Γ=½îππHTIê¬├!Σ=¼å!σ=½ÅµµHTIê└¬¿!τ=½ÅΦΦHTIê└¬ô!Θ=½ìΩΩHTIê└*é *ç" [nil w p "^A-Za-z0-9'" (48 49 50 51 52 53 54 55 56 57 39) "A-Za-z0-9'" 39 -1 "nil" word 0 fc intern conx-words-hashtable boundp vec conx-words-vector-fp conx-words-vector conx-rehash copy-sequence [1 0 0 0 0 0 nil nil 0 0] 65 90 1 conx-last-word 8 6 rel 9 7 n " \n" (44 46 33 63 59) char 44 2 46 59 3 63 4 33 5] 6]] 2)
(fset 'conx-buffer #[nil "¼â┴ ê\n├dèebêî~ê`ëW½ú╚╔├#ê`}ê`bê╩ ê~ê╦╠═_dÑ\"ê¬U*½êCñ╦╨\nZ#+ç" [conx-words-vector conx-init conx-words-vector-fp 0 pm n i p search-forward "\n\n" conxify-internal message "%d%%..." 100 buffer-file-name conx-files "%s words, %d unique"] 5 "\
Absorb the text in the current buffer into the tree." nil])
(fset 'conx-region #[(p m) "î~ê }ê┬ )ç" [p m conx-buffer] 2 "\
Absorb the text in the current region into the tree." "r"])
(fset 'conx-mail-buffer #[nil "èebê└┴wê┴ëëëë╟╚!¼ä╔╩!êm¼¡╦╠┴═#ê`╦╬┴═#ê`ë╧╨┴╤#½è╥`\"╙W½é`╘`\"ê\nbê¬P-¡êCñë)ç" ["\n " nil p3 p2 p buffer-file-name case-fold-search looking-at "^From " error "not in /bin/mail format" search-forward "\n\n" 0 "\nFrom " re-search-backward "\n--+\n" t count-lines 9 conx-region conx-files] 5 "\
Conxify a buffer in /bin/mail format." nil])
(byte-code "└┴Mê┬├Mê─┼Mç" [conx-random-related #[(count list) "┴U½â┴¬ç┬─ \"ª┼½ª@AX½î@@┼ë¬i@AZAë¼Z*ç" [count 0 logand conx-most-positive-fixnum random nil ans foll list] 4] conx-random-succ #[(word) "J┴H┬U½éç├J┴HJ─H\"╞╚ \" ª┬U½Ä╩├J╦HJ╠H\"!¬ü)ç" [word 8 0 conx-random-related 6 next logand conx-most-positive-fixnum random conx-bounce conx-random-succ 9 7] 5] conx-sentence #[nil "┴\n├ \"ªH╞`╔\n╔╔âτ ┴\n├ \"Jë\n═Hª¼ï\n═H\n╬HU½ÿ╔╧!ë═H╨\\cê╬╔Ocê¬à╧!cê\n╤HW½à╥cê¬⌡\n╤HZë\n╙HW½º╔┴\n├ \"╘ª═U½ò┴\n├ \"╒ª═U½à╓cê¬╟╫cê¬┬╪cê¬╜\n╙HZë\n╒HW½ç╔┘cê¬Ñ\n╒HZë\n╘HW½ç╔┌cê¬ì█cê\n▄H═U½é╔â ▌!ëä ▐èbê═yê`)`\"êh▀U½ù┴\n├ \"╒ª═U½àαcê¬çßΓ!êπcê.╔ç" [conx-words-vector logand conx-most-positive-fixnum random conx-words-vector-fp word t first-p p nil vec punc str 0 1 symbol-name -32 2 ", " 3 5 4 ": " "; " ". " "? " "! " " " 8 conx-random-succ fill-region-as-paragraph 10 "\n" delete-char -1 " "] 5]] 2)
(fset 'conx #[nil "└┴┬!q!ê├─┬!!ê┼╞!êdbê╟h╚U½â╔¬ü╩!ê╦ ê¬l" [display-buffer get-buffer-create "*conx*" select-window get-buffer-window message "type ^G to stop." sit-for 10 2 0 conx-sentence] 3 "\
Generate some random sentences in the *conx* buffer." nil])
(fset 'conx-gnus-snarf #[nil "qêèî~êebê┴┬├─#ê┼`d\"*ç" [gnus-Article-buffer search-forward "\n\n" nil t conx-region] 4 "\
For use as a gnus-Select-article-hook."])
(fset 'conx-save #[(file) "è└└Ä┬├!ëqêed|ê─cê┼cê½ï╟╚╔╩#╦▒ê╠═ ╬▒ê`╧╨╤╓cêW½ö╪Hp\"ê┌cêTë¬g█cê▄`\"ê╦cê,▌▐\"êebêαß└Γ#½åπΣ!ê¬sσ&!êτ ê) ¡âΦ !*ç" [nil b get-buffer-create "*conx-save-tmp*" ";;; -*- Mode:Emacs-Lisp -*-\n" ";;; This is a CONX database file. Load it with `conx-load'.\n" conx-files ";;; Corpus: " mapconcat identity ", " "\n" ";;; Date: " current-time-string "\n\n" 78 " " 0 i fill-prefix fill-column p "(!! [ " conx-words-vector-fp prin1 conx-words-vector " " "])\n" fill-region-as-paragraph mapatoms #[(sym) "└ !??¡ô┬cê├ p\"ê─cê├ Jp\"ê┼cç" [boundp sym "(! " prin1 " " ")\n"] 3] conx-words-hashtable re-search-forward "\\bnil\\b" t replace-match "()" set-visited-file-name file save-buffer kill-buffer] 6 "\
Save the current CONX database to a file for future retrieval.
You can re-load this database with the \\[conx-load] command." "FSave CONX corpus to file: "])
(fset 'conx-load #[(file) "└ ê┴┬\"─Mê┴┼\"╞Mê╚ !)ç" [conx-init intern "!!" conx-words-hashtable #[(vec) "Gëç" [vec conx-words-vector conx-words-vector-fp] 2] "!" setq obarray load file] 3 "\
Load in a CONX database written by the \\[conx-save] command.
This clears the database currently in memory." "fLoad CONX corpus from file: "])
(byte-code "└┴Mê┬├!¼é─┬┼!¼é╞╟╚Mê╔╩Mç" [conx-emit-c-data #[nil "└p┴└ëë¼ä╔╩!ê╦═╬\"ê)ƒëG╧_╨╤╥!½ç╙!╘Ѭâ╘Ñ]╦╒└ë┘┌!êâ⌡ @AJë█HT½┤┘@A!ê┘▄!ê┘▌@@\"@!ê┘▄!êTë▐V½ç┘▀!ê╦Aë¼Lαß\nÑ\"êTΓHë½┤┘@A!ê┘▄!ê┘▌@@\"@!ê┘▄!êTë▐V½ç┘▀!ê╦Aë¼Lαß\nÑ\"êTAëäT ,┘π!ê╦Σ└ë%&ë½╟τ@A!ëGT%%\\&%Φ\\\\ë&ΘV½è┘Ω!ê%Φ\\&┘!ê┘δ!êαß\nÑ\"êTAë¼9-┘∞!ê╦ë└ëë-.&ëâZ@.τ.A!-.AJ┘∩!ê┘╦H!ê┘▄!ê┘╨H!ê┘▄!ê┘≡H!ê┘▄!ê┘ΦH!ê┘▄!ê┘╧H!ê┘▄!ê┘╒H!ê█H¼å┘±!ê¬ò┘▄!ê┘!ê█HG≡_\\ΓH¼å┘≥!ê¬Ö┘▄!ê┘!ê┘▄!êΓHG≡_\\┘≤H!ê┘▄!ê┘⌠H!ê┘▄!ê┘&!ê&-G╨\\\\&┘A½Å.@≡ª╦U½â⌡¬ä÷¬ü≈!êαß\nÑ\"êTAëäp.┘°!ê┘9!ê┘▀!êα·!.ç" [nil "%.2f" total100 total count float-output-format standard-output all conx-words-hashtable error "no words" 0 i mapatoms #[(x) "└ !¡è\n BB\nTëç" [boundp x i all] 2] 4 1 featurep lisp-float-type float 100 5 word rest2 rest princ "static unsigned short D[] = {" 7 "," rassq 10 "\n" message "Writing C code... %s%%" 6 "0};\nstatic char T[] = \"" 20 k j symbol-name 3 78 "\\\n" "\\000" "\";\nstatic struct conx_word words [] = {" name cons "{" 2 ",0" ",0," 9 8 "},\n" "}," "}" "};\n#define conx_bounce " conx-bounce "Writing C code... done."] 7] boundp conx-c-prolog "#if __STDC__\n#include <stddef.h>\n#include <unistd.h>\nextern long random (void);\nextern void srandom (int);\nextern void abort (void);\n#endif\n#include <stdio.h>\n#include <time.h>\n\nstruct conx_word {\n unsigned short count;\n unsigned short cap;\n unsigned short comma;\n unsigned short period;\n unsigned short quem;\n unsigned short bang;\n unsigned short pred;\n unsigned short succ;\n unsigned short npred;\n unsigned short nsucc;\n unsigned short text;\n};\n" conx-c-code "#define countof(x) (sizeof((x)) / sizeof(*(x)))\n#define conx_rand(n) (random()%(n))\n\nstatic struct conx_word *\nconx_random_related (count, which_list)\n unsigned short count, which_list;\n{\n unsigned short *list = D + which_list;\n int i = 0;\n unsigned short foll = (count == 0 ? 0 : conx_rand (count));\n while (1)\n {\n if (foll <= list [i * 2])\n {\n if ((list [i * 2 + 1]) > countof (words))\n abort ();\n return &words [list [i * 2 + 1]];\n }\n foll -= list [i * 2];\n i++;\n }\n}\n\nstatic struct conx_word *\nconx_random_succ (word)\n struct conx_word *word;\n{\n if (word->nsucc == 0)\n return word;\n else\n {\n struct conx_word *next = conx_random_related (word->nsucc, word->succ);\n if (conx_rand (conx_bounce) != 0)\n return next;\n return conx_random_succ (conx_random_related (next->npred, next->pred));\n }\n}\n\nstatic void\nconx_sentence ()\n{\n static int x = 0;\n struct conx_word *word = 0;\n int first_p = 1;\n int done = 0;\n int count = 0;\n while (!done)\n {\n int punc;\n char *text;\n int L;\n if (word)\n word = conx_random_succ (word);\n else\n word = &words [conx_rand (countof (words))];\n count++;\n punc = conx_rand (word->count);\n text = T + word->text;\n L = strlen (text);\n if (x + L > 70)\n {\n putchar ('\\n');\n x = 0;\n }\n x += L+1;\n\n if (first_p || (word->count == word->cap))\n {\n putchar ((*text >= 'a' && *text <= 'z') ? *text + ('A'-'a') : *text);\n fputs (text+1, stdout);\n first_p = 0;\n }\n else\n fputs (text, stdout);\n\n if (punc < word->comma)\n {\n fputs (\", \", stdout);\n x++;\n }\n else if ((punc -= word->comma) < word->period)\n {\n x++;\n if (count > 120 || conx_rand (5) != 0)\n {\n done = 1;\n fputs (\". \", stdout);\n x++;\n }\n else\n {\n word = 0;\n if (conx_rand (4) == 0)\n fputs (\": \", stdout);\n else\n fputs (\"; \", stdout);\n }\n }\n else if ((punc -= word->period) < word->quem)\n {\n done = 1;\n fputs (\"? \", stdout);\n x += 2;\n }\n else if ((punc -= word->quem) < word->bang)\n {\n done = 1;\n fputs (\"! \", stdout);\n x += 2;\n }\n else\n {\n if (word->nsucc == 0)\n {\n fputs (\". \", stdout);\n x += 2;\n done = 1;\n }\n else\n putchar (' ');\n }\n }\n if (conx_rand (3) == 0)\n {\n fputs (\"\\n\\n\", stdout);\n x = 0;\n }\n}\n\nmain (argc, argv)\n int argc;\n char **argv;\n{\n unsigned int howmany, delay;\n char dummy;\n if (argc == 1)\n {\n howmany = 1;\n delay = 0;\n }\n else if (argc == 2 &&\n 1 == sscanf (argv[1], \"%ud%c\", &howmany, &dummy))\n delay = 0;\n else if (argc == 3 &&\n 1 == sscanf (argv[1], \"%ud%c\", &howmany, &dummy) &&\n 1 == sscanf (argv[2], \"%ud%c\", &delay, &dummy))\n ;\n else\n {\n fprintf (stderr, \"usage: %s [count [delay]]\\n\", argv [0]);\n exit (1);\n }\n\n srandom (time (0));\n if (howmany == 0)\n howmany = ~0;\n while (howmany > 0)\n {\n conx_sentence ();\n fflush (stdout);\n howmany--;\n if (delay) sleep (delay);\n }\n putchar ('\\n');\n exit (0);\n}\n" conx-emit-c #[(file) "└ !ê┬ ê├cê╞ êcê)ebç" [find-file file erase-buffer t buffer-undo-list conx-c-prolog conx-emit-c-data conx-c-code] 2 nil "FWrite C file: "] conx-stats #[nil "└┴!qêed|ê┬├\"ê┼╞ed#ç" [get-buffer-create "*conx-stats*" mapatoms #[(x) "└ !?«ô┬├ J─H\"cê┼cê╞ !cê╟cç" [boundp x format "%s" 0 " " symbol-name "\n"] 4] conx-words-hashtable sort-numeric-fields -1] 4]] 2)